﻿@model GitCandy.Models.PathBarModel

<ul class="breadcrumb">
    <li>@Html.ActionLink(Model.Name, Model.Action, Html.OverRoute(new { path = (Model.ReferenceName ?? Model.ReferenceSha) }))</li>

    @if (!string.IsNullOrEmpty(Model.Path))
    {
        var dirs = Model.Path.Split('/');
        var length = dirs.Length;
        var currentPath = string.Empty;
        for (var i = 0; i < length; i++)
        {
            if (i != 0)
            {
                currentPath += "/" + dirs[i];
            }
            else
            {
                currentPath += dirs[i];
            }
            if (i + 1 == length)
            {
                <li class="active">
                    @dirs[i]
                </li>
            }
            else
            {
                <li>@Html.ActionLink(dirs[i], Model.Action, Html.OverRoute(new { path = (Model.ReferenceName ?? Model.ReferenceSha) + "/" + currentPath })) </li>
            }
        }
    }
</ul>
